package cn.socket.udp;

import java.io.IOException;
import java.net.*;

/**
 * udp 快速入门 发送口
 */
public class UdpSend {
    public static void main(String[] args) throws IOException {
        //socket 子类
        DatagramSocket ds=new DatagramSocket();
        InetAddress inetAddress=InetAddress.getByName("LAPTOP-VB8QSKVB");
        //封装数据
        byte[] data="hello i am udp".getBytes();
        int len=data.length;
        DatagramPacket packet=new DatagramPacket(data,0,len,inetAddress,10086);
        //发送数据
        ds.send(packet);
        //关闭DatagramSocket
        ds.close();
    }
}
